#include<bits/stdc++.h>
using namespace std;
int t,n,m,l,u,d[100005],a[100005],v[100004],num,ans,m1,p[100005],w[100005];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
cin>>t;
for(int o=1;o<=t;o++)
{
   cin>>n>>m>>l>>u;
   //cout<<"d"<<" ";
    for(int i=1;i<=n;i++)
    {
    cin>>d[i]>>v[i]>>a[i];
    d[i]=l-d[i];
    //cout<<d[i]<<" ";
    }
  //  cout<<"d"<<" ";
    for(int i=m;i>=1;i--)
    {
        cin>>p[i];
        p[i]=l-p[i];
      //  cout<<p[i]<<" ";
    }
    for(int i=1;i<=n;i++)
    {
   //     cout<<i<<a[i];
    if(a[i]>=0){
    if(d[i]>=p[1]&&(u*u<2*a[i]*(d[i]-p[1])+v[i]*v[i]))
    {
    num++;
    //cout<<i;
    if(!w[1]){
    w[1]=1;
    ans++;
    //cout<<i<<" ";
    }
    }
    }
    if(a[i]<0)
    {
    for(int j=m;d[i]>=p[j]&&j>=1;j--)
    {
        //cout<<"d"<<d[i]<<" "<<p[i];
    m1=j;
  //  if(m1)
    //cout<<m1<<" ";
    }

    if(m1&&(u*u<2*a[i]*(d[i]-p[m1])+v[i]*v[i]))
    {
        //cout<<i<<" ";
    num++;
   // cout<<i;
    if(!w[m1]){
    w[m1]=1;
   // cout<<i<<" ";
    ans++;
    }
    }
    }
    }
    cout<<num<<" "<<m-ans<<"\n";
    num=0;
    ans=0;
    for(int i=1;i<=m;i++)
    {
        w[i]=0;

    }
    m=0;
}
return 0;

}
